
package cn.xuguowen.tool;

import java.text.SimpleDateFormat;

/**
 * ClassName: ExportWordUtil
 * Package: cn.xuguowen.tool
 * Description:
 * SimpleDateFormat线程安全
 *
 * @Author 徐国文
 * @Create 2023/4/1 17:06
 * @Version 1.0
 */
public class SimpleDateFormatUtils {

    private static final ThreadLocal<SimpleDateFormat> THREAD_LOCAL = new ThreadLocal<SimpleDateFormat>() {
        @Override
        protected SimpleDateFormat initialValue() {
            return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        }
    };

    public static SimpleDateFormat getTime() {
        SimpleDateFormat simpleDateFormat = THREAD_LOCAL.get();
        if(simpleDateFormat == null){
            return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        }
        return simpleDateFormat;
    }

}